﻿<!-- reg1.php 用于将注册用户的信息录入数据库。 -->
<html lang="en">
 <head>
  <meta charset="UTF-8">
 </head>
 <body>
<?php
  //获取前一个页面客户提交的信息，使用POST方法提交的信息存放在$_POST数组中。
  // $username = trim($_POST['username']);
  // $pwd = $_POST['pwd'];
  // $gebder = $_POST['gender'];
  // $hobby = implode('，', $_POST['hobby']);
  // $degree = $_POST['degree'];
  // $intro = $_POST['intro'];

  $host = "localhost:3306";
  $user = "root";
  $pass = "";
  $link = mysql_connect($host,$user,$pass) or die(mysql_error());
  mysql_select_db("test",$link) or die(mysql_error());
  mysql_set_charset('utf8', $link);
  
  // $sql = "insert into user values(null,'$username',md5('$pwd'),'$gender','$hobby','$degree','$intro')";
  $sql = "insert into user values(null,'232','122','0','er','f','dfd')";
  echo $sql.'<br/>';
  
  $result = mysql_query($sql) or die(mysql_error());  
  $num = mysql_affected_rows();
  if($num!=1){
	  echo "注册失败！";
	  //header("location:reg.html");
  }else{	  
	  echo "注册成功！<br/>";
	  echo "请使用管理员<a href='login.html'>登录</a>查看用户信息";
	  echo "，或返回<a href='reg.html'>返回</a>注册页面！";
	  //header("location:login.html");
	  //$_SESSION();
  }  
  mysql_close();
?>
</body>
</html>